Introduction
Always we need privacy on our mobile's, so we need to prevent any one working on device also some time you need to make sure the employee now playing in device "just work in specific application"
Not solitare ..etc
Background
Every object on main screen or any where like start menu and sip …etc it’s just window so what we can do to make our dream true, the answer to simple FindWindow
and subclass it no more
In our case we have to find handel for main screen we can find any window by Microsoft Visual Studio Remote tools.
What I mean on MS_SIPBUTTON
Before start
Before we begin in this article I thought you have experince in SubClassing window, and Findwindow if not please read more about it here
FindWindow :http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499(v=vs.85).aspx
GetWindowLong: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633584(v=vs.85).aspx
Using the Code
Now let's talk about how find window by M.S Function and do what we want once we got the handle
- To Find MS_SIPBUTTON Class (to Disable SIP Button)
HWND m_SipButton=::FindWindow(L"MS_SIPBUTTON",L"MS_SIPBUTTON");
m_SipButton=::GetWindow(m_SipButton,GW_CHILD);
if(m_SipButton)
{
::ShowWindow(m_SipButton,SW_HIDE);}
We got handle for sip Class ,then simply hide it by Call ShowWindow
Function.
NOTE :you should save m_SipButton
handle, because in case you to show window again just call
HWND m_SipButton=::FindWindow(L"MS_SIPBUTTON",L"MS_SIPBUTTON");
::ShowWindow(m_SipButton,SW_SHOW);
- To Find
HHTaskBar
Class (to Disable Any Click on main Screen)
if(m_hWndStart)
{
m_startProc =(WNDPROC)::GetWindowLong(m_hWndStart,GWL_WNDPROC);
::SetWindowLong(m_hWndStart,GWL_WNDPROC,(LONG)StartPRoc);}
The Point from SubClass HHTaskBar
it's catch All windows messages before sent it to Main Screen Window, you can read more about SubClass ,it's heart of Object Oriented
- Now Lets Explain
StartProc
SubClassing
static LRESULT WINAPI StartPRoc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_KEYDOWN:
case WM_LBUTTONDOWN:
{
POINT pt;
RECT rc={0,0,440,64}; pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
if (PtInRect(&rc,pt))
{
MessageBeep(0);
return 0;
}
else
{
return CallWindowProc(m_startProc,hWnd,WM_LBUTTONDOWN,wParam,lParam);
}
return 0;
}
Default:
return CallWindowProc(m_startProc,hWnd,uMsg,wParam,lParam);}
Above code too simple: what we do actually Catch All messages before sent it to Original proc and override WM_KEYDOWN
+ WM_LBUTTONDOWN
by enforce him to return 0
no more (I mean handle any click inside main screen) I love to make my Article As Simple As Possible